package exercise;

class Computer {
    String brand;
    int cpuHz; // CPU频率
}

class SxtStu {
    // field
    int id;
    String sname;
    int age;
    Computer comp;

    void study() {
        System.out.println("我正在学习使用我的电脑！姓名:" + sname + "  品牌：" + comp.brand + "  cpu:" + comp.cpuHz);
    }

    SxtStu() {
    }

    public static void main(String[] args) {
        // 创建学生对象并设置相关信息
        SxtStu s1 = new SxtStu();
        s1.sname = "张三";
        Computer c1 = new Computer();
        c1.brand = "华硕";
        c1.cpuHz = 5; // 设置CPU频率为5GHz
        s1.comp = c1; // 将电脑信息关联到学生

        SxtStu s2 = new SxtStu();
        s2.sname = "赵四";
        Computer c2 = new Computer();
        c2.brand = "联想";
        c2.cpuHz = 6; // 设置CPU频率为6GHz
        s2.comp = c2; // 将电脑信息关联到学生

        SxtStu s3 = new SxtStu();
        s3.sname = "李五";
        Computer c3 = new Computer();
        c3.brand = "惠普";
        c3.cpuHz = 4; // 设置CPU频率为4GHz
        s3.comp = c3; // 将电脑信息关联到学生

        // 调用学习方法，输出信息
        s1.study();
        s2.study();
        s3.study();
    }
}